package src.com.atguigu05.exer.exer1;

import src.com.atguigu08._interface.exer2.Circle;
import src.com.atguigu08._interface.exer2.CompareObject;
import src.com.atguigu08._interface.exer2.CompareableCircle;

/**
 * ClassName: CompareableCircleTest
 * Package: src.com.atguigu05.exer.exer1
 * Description:
 *
 * @Author BuTang
 * @Create 2023/5/4 14:59
 * @Version 1.0
 */
public class CompareableCircleTest extends Circle implements CompareObject{
    public int compareTo(Object o) {
        if(this == o){
            return 0;
        }
        else if(o instanceof CompareableCircle){
           CompareableCircle c  = (CompareableCircle) o;
            if ( this.getRadius() > c.getRadius()) {
                return 1;
            }
            if (this.getRadius() == c.getRadius()){
                return 0;
            }
            if (this.getRadius() < c.getRadius()){
                return -1;
            }
        }
        try {
            throw new InstaticException("类型错误");
        }catch (InstaticException e){
            e.printStackTrace();
        }finally {
            return -999;
        }
    }
}
